fn main() {
    // let mut s = String::from("hello");
    // s.push_str(",world");
    // println!("the value type is String,value is {}", s);

    // let s1 = String::from("hello");
    // // let s2 = s1;
    // let s2 = s1.clone();
    // println!("{},{}", s1, s2);
    // println!("{}", s1);

    // let str = String::from("hello");
    // take_ownership(str);
    // //error str value is move
    // // println!("{}", str);
    // let x = 5;
    // makes_copy(x);
    // //success x value is copy
    // println!("{}", x);

    // let s1 = get_ownership();
    // let s2: String = String::from("world");
    // let s3 = takes_and_get_back(s2);

    // println!("{}", s1);
    // println!("{}", s3);
    // println!("{}", s3);

    let s1 = String::from("hello");
    //is move and back
    // let (s2, len1) = caculate_length(s1);
    // println!("{},{}", s2, len1);

    //
    let len2 = caculate_length02(&s1);
    println!("{}", s1);
    println!("{},{}", s1, len2);
}
fn caculate_length(some_string: String) -> (String, usize) {
    let len = some_string.len();
    (some_string, len)
}
fn caculate_length02(some_string: &String) -> usize {
    let len = some_string.len();
    len
}

/* fn take_ownership(some_string: String) {
    println!("{}", some_string);
}

fn makes_copy(some_number: i32) {
    println!("{}", some_number);
}

fn get_ownership() -> String {
    let some_string = String::from("hello");
    some_string
}

fn takes_and_get_back(some_string: String) -> String {
    some_string
}
 */
